﻿using GpCommon.Models;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace FirstLimitUpMode.Models
{
    /// <summary>
    /// 股票对象
    /// </summary>
    public class GpEntity : BindableBase
    {
        private int m_Num;

        public int Num
        {
            get { return m_Num; }
            set
            {
                m_Num = value;
                RaisePropertyChanged();
            }
        }
        private string m_Code;

        public string Code
        {
            get { return m_Code; }
            set
            {
                m_Code = value;
                RaisePropertyChanged();
            }
        }
        private string m_Name;

        public string Name
        {
            get { return m_Name; }
            set
            {
                m_Name = value;
                RaisePropertyChanged();
            }
        }
        private float m_CurPrice;

        public float CurPrice
        {
            get { return m_CurPrice; }
            set
            {
                m_CurPrice = value;
                RaisePropertyChanged();
            }
        }
        private float m_CurMarkUp;
        /// <summary>
        /// 涨幅
        /// </summary>
        public float CurMarkUp
        {
            get { return m_CurMarkUp; }
            set
            {
                m_CurMarkUp = value;
                RaisePropertyChanged();
            }
        }
        private float m_CurAccer;
        /// <summary>
        /// 涨速
        /// </summary>
        public float CurAccer
        {
            get { return m_CurAccer; }
            set
            {
                m_CurAccer = value;
                RaisePropertyChanged();
            }
        }

        private float m_TotalValue;
        /// <summary>
        /// 总市值
        /// </summary>
        public float TotalValue
        {
            get { return m_TotalValue; }
            set 
            { 
                m_TotalValue = value;
                RaisePropertyChanged();
            }
        }

        private float m_MoveValue;
        /// <summary>
        /// 流通市值
        /// </summary>
        public float MoveValue
        {
            get { return m_MoveValue; }
            set
            {
                m_MoveValue = value;
                RaisePropertyChanged();
            }
        }
        private int m_LastTopCount;
        /// <summary>
        /// 一个月内涨停
        /// </summary>
        public int LastTopCount
        {
            get { return m_LastTopCount; }
            set
            {
                m_LastTopCount = value;
                RaisePropertyChanged();
            }
        }
        private string m_LastTopStr;
        /// <summary>
        /// 一个月内涨停/最高点涨停
        /// </summary>
        public string LastTopStr
        {
            get { return m_LastTopStr; }
            set
            {
                m_LastTopStr = value;
                RaisePropertyChanged();
            }
        }
        private bool m_IsLock = false;
        /// <summary>
        /// 是否是自选
        /// </summary>
        public bool IsLock
        {
            get { return m_IsLock; }
            set
            {
                m_IsLock = value;
                RaisePropertyChanged();
            }
        }

        private int m_Status = 0;
        /// <summary>
        /// 状态   0 普通   1 下单    2 意愿
        /// </summary>
        public int Status
        {
            get { return m_Status; }
            set
            {
                m_Status = value;
                RaisePropertyChanged();
            }
        }

        private ImageSource m_LineImage;
        /// <summary>
        /// 分时图线
        /// </summary>
        public ImageSource LineImage
        {
            get { return m_LineImage; }
            set
            {
                m_LineImage = value;
                RaisePropertyChanged();
            }
        }


        private System.Windows.Media.Brush m_BackColorForCurAccer = new SolidColorBrush(Colors.White);

        public System.Windows.Media.Brush BackColorForCurAccer
        {
            get
            {
                if (m_CurAccer > 1.5)
                {
                    return new SolidColorBrush(Colors.LightGray);
                }
                //else if(m_CurAccer < 0)
                //{
                //    return new SolidColorBrush(Colors.Green);
                //}
                else
                {
                    return new SolidColorBrush(Colors.White);
                }
            }
            set
            {
                m_BackColorForCurAccer = value;
                RaisePropertyChanged();
            }
        }
        private System.Windows.Media.Brush m_ForeColorForMarkUp = new SolidColorBrush(Colors.White);

        public System.Windows.Media.Brush ForeColorForMarkUp
        {
            get
            {
                //if (m_CurMarkUp > 0)
                //{
                //    return new SolidColorBrush(Colors.Red);
                //}
                //else if(m_CurMarkUp < 0)
                //{
                //    return new SolidColorBrush(Colors.Green);
                //}
                //else
                {
                    return new SolidColorBrush(Colors.Black);
                }
            }
            set
            {
                m_ForeColorForMarkUp = value;
                RaisePropertyChanged();
            }
        }


        public static GpEntity ConvertBy(GpCurEntity curEntity)
        {
            GpEntity ent = new GpEntity();
            ent.Code = curEntity.Code;
            ent.Name = curEntity.Name;
            ent.CurPrice = curEntity.CurPrice;
            ent.CurMarkUp = curEntity.CurMarkUp;
            ent.TotalValue = curEntity.TotalMarketValue;
            ent.MoveValue = curEntity.MoveMarketValue;
            return ent;
        }
    }
}
